<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>注册</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="robots" content="all,follow">
    <!-- Bootstrap CSS-->
    <link rel="stylesheet" href="vendor/bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome CSS-->
    <link rel="stylesheet" href="vendor/font-awesome/css/font-awesome.min.css">
    <!-- Fontastic Custom icon font-->
    <link rel="stylesheet" href="css/fontastic.css">
    <!-- Google fonts - Poppins -->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins:300,400,700">
    <!-- theme stylesheet-->
    <link rel="stylesheet" href="css/style.default.css" id="theme-stylesheet">
    <!-- Custom stylesheet - for your changes-->
    <link rel="stylesheet" href="css/custom.css">
    <!-- Favicon-->
    <link rel="shortcut icon" href="img/favicon.ico">
    <!-- Tweaks for older IEs--><!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script><![endif]-->
  </head>
  <body>
    <div class="page login-page">
      <div class="container d-flex align-items-center">
        <div class="form-holder has-shadow">
          <div class="row">
            <!-- Logo & Information Panel-->
            <div class="col-lg-6">
              <div class="info d-flex align-items-center">
                <div class="content">
                  <div class="logo">
                    <h1>web房地产价值评估</h1>
                  </div>
                  <p>Web-based real estate valuation system.</p>
                </div>
              </div>
            </div>
            <!-- Form Panel    -->
            <div class="col-lg-6 bg-white">
              <div class="form d-flex align-items-center">
                <div class="content">
                  <form class="form-validate">
                    <div class="form-group">
                      <input id="register-username" type="text" name="registerUsername" required data-msg="Please enter your username" class="input-material">
                      <label for="register-username" class="label-material">User Name</label>
                    </div>
                    <div class="form-group">
                      <input id="register-conpanyaccount" type="text" name="registerEmail" required data-msg="Please enter a valid company account" class="input-material">
                      <label for="register-conpanyaccount" class="label-material">企业主账号      </label>
                    </div>
                    <div class="form-group">
                      <input id="register-password" type="password" name="registerPassword" required data-msg="Please enter your password" class="input-material">
                      <label for="register-password" class="label-material">password        </label>
                    </div>
                    <div class="form-group">
                      <input id="register-repassword" type="password" name="registerPassword" required data-msg="Please enter your password again" class="input-material">
                      <label for="register-repassword" class="label-material">repeat password        </label>
                    </div>
                    <div class="form-group terms-conditions">
                      <input id="register-agree"  name="registerAgree" type="checkbox" required value="1" data-msg="Your agreement is required" class="checkbox-template">
                      <label for="register-agree">同意用户使用协议</label>
                    </div>
                    <div class="form-group">
                      <button id="regidter" type="button" class="btn btn-primary">注册</button>
                    </div>
                  </form><small>已有账户? </small><a href="login.html" class="signup">登录</a>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="copyrights text-center">
        <p>Developed by <a href="#" class="external">Yang.Xing</a>
          <!-- Please do not remove the backlink to us unless you support further theme's development at https://bootstrapious.com/donate. It is part of the license conditions. Thank you for understanding :)-->
        </p>
      </div>
    </div>
    <!-- JavaScript files-->
    <script src="vendor/jquery/jquery.min.js"></script>
    <script src="vendor/popper.js/umd/popper.min.js"> </script>
    <script src="vendor/bootstrap/js/bootstrap.min.js"></script>
    <script src="vendor/jquery.cookie/jquery.cookie.js"> </script>
    <script src="vendor/chart.js/Chart.min.js"></script>
    <script src="vendor/jquery-validation/jquery.validate.min.js"></script>
    <!-- Main File-->
    <script src="js/front.js"></script>
    <script type="text/javascript">


      $("#regidter").bind("click",function(){
          var username = $("#register-username").val();
          var companyaccount = $("#register-conpanyaccount").val();
          var password = $("#register-password").val();
          var repass = $("#register-repassword").val();

          if(!document.getElementById("register-agree").checked){
              alert("请同意用户使用协议");
              return;
          }
          if(username==""){
              $("#register-username").focus();
              return;
          }
          if(companyaccount==""){
              $("#register-conpanyaccount").focus();
              return;
          }
          if(password==""){
              $("#register-password").focus();
              return;
          }
          if(repass==""){
              $("#register-repassword").focus();
              return;
          }
          if(password!=repass){
              alert("两次密码输入不一致!");
              $("#register-password").val("");
              $("#register-repassword").val("");
              return;
          }
          $.ajax({
              type:"get",
              url:"/login.spr",
              contentType:"application/json",
              dataType: "json",
              data:{
                  'method':"regsist",
                  'username':username,
                  'password':password,
                  'companyaccount':companyaccount
              },
              success:function(data){
                  var dataObj=eval("("+data+")");

                  if(dataObj.result!="0000"){
                      alert(dataObj.msg);
                  }else{
                      alert("注册成功！");
                      window.location.href = "/login.html";
                  }
              },
              error:function(){
                  alert("注册失败！");

              }
          });
      });


    </script>
  </body>
</html>